// 格式化价钱
export const formatPrice = (price: number, dig = 1) => {
    const n = Math.floor(price);
    if (n == price) return n;
    return Number(price.toFixed(dig))
}

// 函数防抖
// debounce.js
export const debounce = (fn: Function,time=1000)=>{
    let timer: any = null;
    return (...args: any[])=>{
        // 设置新的之前把老的给清除
        if(timer) {
            console.log("clear")
            clearTimeout(timer)
            timer = null
        }
        timer=setTimeout(()=>{
            fn(...args)
        },time)
    }
}
